import React, {useEffect, useState} from 'react';
import {List} from 'antd-mobile';
import Txt from "../../../components/txt/Txt";
import Btn from "../../../components/btn/Btn";
import './Yuyue2.less';
import http from "../../../model/http";
import UserMsg from "../userMsg/UserMsg";
const Item = List.Item;

function Yuyue2() {
  const query = http.useQuery(),
      hosId = query.get('hosId');
  const [data,setData] = useState({});

  useEffect(()=>{
    (async ()=>{
      const yuyue = await http.outPost('/customer/schedulerDetail',{
        hosId:hosId,schedulerId:query.get('orderId'),customerCrmId:query.get('crmId')
      })
      let projectNameString = ''
      for(let i in yuyue.systemtrinfo){
        projectNameString +=`${Number(i)+1}、${yuyue.systemtrinfo[i].trname}<br/>`
      }

      yuyue.projectNameString = projectNameString
      // yuyue.projectNameString = yuyue.systemtrinfo.map((item,index) => {
      //   return yuyue.projectNameString +=`${index+1}、${item.trname}<br/>`
      // })
      setData(yuyue)
      
      console.log(yuyue)
    })()
    // eslint-disable-next-line
  },[])

  
  
  
  const showhtml = (htmlString) => {
    var html = {__html:htmlString};
    return  <div dangerouslySetInnerHTML={html}></div> ;
  }

  return data.sdate ? (
    <div className='v-yuyue-notice2'>
      <UserMsg hosId={hosId}
               title={(<div className='g-ta-c g-mt10'>
                 <Txt>预约到院治疗时间</Txt>
                 <p className='g-mt10 g-mb10' style={{fontSize:'28px'}}>{data.sdate}</p>
                 <p className='g-mb10 g-mb10' style={{fontSize:'28px'}}>{data.begintime} ~ {data.endtime}</p>
               </div>)} 
               push={(<>
               
                  
                 {<Item wrap extra={data.sch_status == '系统'?showhtml(data.projectNameString):showhtml(data.trInfo)}>治疗项目</Item> }
                 <Item extra={data.expertName}>治疗医生</Item>
               </>)}
               msg={data.customerInfo.baseInfo[0]} />

      {/* {data.memo ? (<div className='g-mt10 g-mb30 v-lh20 g-c8 g-f12'>
        <p className='g-f14'>注意事项</p>
        <div dangerouslySetInnerHTML={{__html: data.memo}}></div>
      </div>):null} */}

      {/* <Btn type='primary'>确定</Btn> */}
    </div>
  ):null
}

export default Yuyue2;